/*
entityName: my_software_blogg_metadata
rssUrl: http://tobias-ericsson-sw-development.blogspot.com/feeds/posts/default
lastModified: 

entityName: my_personal_blogg_metadata
rssUrl: http://tobias-ericsson-sw-development.blogspot.com/feeds/posts/default
lastModified:  
*/

import com.google.appengine.api.datastore.Entity

String rssUrl = request.getParameter("url")
String entityName = request.getParameter("name")
String lastModified = request.getParameter("modified")
String categoriesEntityName = request.getParameter("categories_name")
String headerFile = request.getParameter("header")
String feedName = request.getParameter("feed_name")

log.info "rssUrl " + rssUrl
log.info "entityName " + entityName
log.info "lastModified " + lastModified

if (rssUrl && entityName) {
    Entity entity = new Entity("metadata", rssUrl)
    entity.entityName = entityName
    entity.feedName = feedName
    entity.categoriesEntityName = categoriesEntityName
    entity.headerFile = headerFile
    entity.rssUrl = rssUrl
    entity.lastModified = lastModified
    entity.save()

    out.println "<h1>Stored to Metadata DB</h1>"
    out.println "<br/>feedName: " + feedName
    out.println "<br/>rssUrl: " + rssUrl
    out.println "<br/>entityName: " + entityName
    out.println "<br/>headerFile: " + headerFile
    out.println "<br/>categoriesEntityName: " + categoriesEntityName
    out.println "<br/>lastModified: " + lastModified
}
else {
    out.println "<h2>Available parametes {url,name,modified,categories_name,header,feed_name}. <br/> Parameter url and name can not be null.</h2>"
}
